<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>08_表单输入绑定</title>
</head>
<body>
<!--
1. 使用v-model(双向数据绑定)自动收集数据
  text/textarea
  checkbox
  radio
  select
-->
<div id="demo">
  <form action="/xxx" @submit.prevent="handleSubmit">
    <span>用户名: </span>
    <input type="text" v-model="userFormData.username"><br>

    <span>密码: </span>
    <input type="password" v-model="userFormData.password"><br>

    <span>性别: </span>
    <input type="radio" id="female" v-model="userFormData.gender" :value="0">
    <label for="female">女</label>
    <input type="radio" id="male" v-model="userFormData.gender" :value="1">
    <label for="male">男</label><br>

    <span>爱好: </span>
    <input type="checkbox" id="basket" v-model="userFormData.hobbies" value="basketball">
    <label for="basket">篮球</label>
    <input type="checkbox" id="foot" v-model="userFormData.hobbies" value="football">
    <label for="foot">足球</label>
    <input type="checkbox" id="pingpang" v-model="userFormData.hobbies" value="pingpang">
    <label for="pingpang">乒乓</label><br>

    <span>城市: </span>
    <select v-model="userFormData.city">
      <option value="">未选择</option>
      <option value="beijing">北京</option>
      <option value="shenzhen">深圳</option>
      <option value="shanghai">上海</option>
      <option value="wuhan">武汉</option>
      <option value="xian">西安</option>
    </select><br>
    <span>介绍: </span>
    <textarea rows="10" v-model="userFormData.intro"></textarea><br><br>

    <input type="submit" value="注册">
  </form>
</div>

<script type="text/javascript" src="../js/vue.js"></script>
<script type="text/javascript">
    new Vue({
      el:'#demo',
      data:{
        userFormData:{
          username:'',
          password:'',
          gender: 0,
          hobbies:[],
          city:'',
          intro:''
        }

      }
    })

</script>
</body>
</html>